<template>
	<div>
	   <Card class="content-card">
	  <Tabs :animated="false">
	    <ButtonGroup slot="extra">
			
	    </ButtonGroup>
	    <TabPane label="主机厂列表" name="factory">
	       <div style="margin-bottom:10px;" >
	            <Button type="primary" size="small" @click="addFactory">新增</Button>
	       </div>
	            <table-view ref="tableView" :tableCol='tableCol' :params='params' :requestUrl='requestUrl'></table-view>
	    </TabPane>
	  </Tabs>
	</Card>
	<factoryOpe ref="factoryOpe" :type='modalType' @table='operationDone'></factoryOpe>
</div>
</template>

<script>
	import tableView from '../../components/table'
	import {formatDate} from '../utils/time.js'
	import factoryOpe from './factoryOpe'
	export default {
	    components:{
	        tableView,
			factoryOpe
	    },
	    data(){
	        return {
	            requestUrl:'/factory/list',
				  genderList:{
				   0:'保密',1:'男',2:'女'
				},
	            tableCol:[
	               {
	                   title:'序号',
	                   type:'index',
	                   width:70
	               },{
	                   title:'账号',
	                   minWidth:180,
					  render:(h,params)=>{
						  return h('div',params.row.userName);
					  }
					  
	               },{
	                   title:'企业名称',
	                   key:'factoryName',
	                   minWidth:180
	               },{
	                   title:'联系人',
	                   key:'factoryUser',
	                   minWidth:150
	               },{
	                   title:'手机号',
	                   minWidth:80,
	                   key:'factoryTel'
	               },{
	                   title:'状态',
	                   minWidth:80,
					    render:(h,params)=>{
					       return h('div',params.row.isOpen==0?'开启':'关闭')
					   }
	               },{
	                   title:'注册时间',
	                   minWidth:80,
	                   key:'createTime',
					   render:(h,params)=>{
						  return h('div',formatDate(new Date(params.row.createTime),'yyyy-MM-dd hh:mm'))
					  }
	               },{
	                   title:'操作',
	                   key:'action',
	                   minWidth:200,
	                   render:(h,params)=>{
	                       return h('div',[
	                           h('Button',{
	                               props:{
	                                   type:'primary',
	                                   size:'small'
	                               },
	                               style:{
	                                   marginLeft:'10px'
	                               },
	                               on:{
	                                  click:()=>{
	                                       this.modalType = 'edit'
	                                       this.$refs['factoryOpe'].show(params)
	                                  }
	                               }
	                           },'编辑')
	                       ])
	                   }
	               }
	
	            ],
	            params:{
	                pageNo:1,
	                pageSize:10
	            },
	            modalType:''
	        }
	    },
		mounted() {
		   
		},
	    methods:{
			addFactory(){
			    this.modalType = 'add'
			    this.$refs['factoryOpe'].show()
			},
	        refreshData(){
	            this.$refs['tableView'].getData()
	        },
	        operationDone(){
	            this.$refs['tableView'].getData()
	        }
	    }
	}
	
</script>

<style>
</style>

